package org.springblade.modules.repair.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.repair.enums.EmerProcTypeEnum;
import org.springblade.modules.repair.enums.MaintainPlanContentEnum;
import org.springblade.modules.repair.enums.TaskStatusEnum;
import org.springblade.modules.repair.enums.WorkOrderTypeEnum;

import java.util.Date;
import java.util.List;

/**
 * @Date 9:54 2022/7/1
 * @Description {
 *   部件申请记录列表 部件更换
 * }
 * @Author lsay
 **/
@Data
public class ElevatorMalfunctionPartsVO {

    /**
     * 工单id
	 */
	@JsonSerialize(using = ToStringSerializer.class)
	private Long planId;

	/**
	 * 电梯id
	 */
	@JsonSerialize(using = ToStringSerializer.class)
	private Long elevatorId;

	private String taskId;

	private String processInstanceId;
	private String buildingName;

	private String elevatorAddress;

    /**
     * 工单类型
	 */
	private Integer typeStatus;
	private String typeStatusName;

	/**
	 * 部件名称
	 */
	private String partsName;

	/**
	 * 层站ids
	 */
	private String floorStandIds;

	/**
	 * 层站名称
	 */
	private String floorStandNames;

	/**
	 * 部件型号
	 */
	private String partsModel;

	/**
	 * 部件数量
	 */
	private Integer num;

	/**
	 * 关联维修任务id
	 */
	@JsonSerialize(using = ToStringSerializer.class)
	private Long malPlanId;

	/**
	 * 故障现象
	 */
	private String problemItem;

	private String problemOtherDesc;

	private String mfDesc;

	/**
	 * 故障现象描述
	 */
	private List<String> problemItemNames;

	/**
	 * 申请人
	 */
	private String createUserName;

	/**
	 * 申请时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;

	/**
	 * 审批节点
	 */
	private String auditNode;

	/**
	 * 工单状态
	 */
	private Integer status;

	/**
	 * 工单状态描述
	 */
	private String statusName;

	/**
	 * 审批状态描述
	 */
	private String auditStatusName;

	/**
	 * 紧急程度
	 */
	private Integer emerProcType;

	/**
	 * 工单类型
	 */
	private Integer workOrderType;

	/**
	 * 紧急程度描述
	 */
	private String emerProcTypeName;

	/**
	 * 工单类型描述
	 */
	private String workOrderTypeName;

	private String malPartsNames;

	public void setPartsName(String partsName) {
		if(Func.isNotEmpty(partsName)){
			this.partsName = partsName.replace("&amp;&amp;",">");
		}
	}

	public void setMalPartsNames(String malPartsNames) {
		if(Func.isNotEmpty(malPartsNames)){
			this.malPartsNames = malPartsNames.replace("&amp;&amp;",">");
		}
	}

	public void setEmerProcType(Integer emerProcType) {
		if(Func.isNotEmpty(emerProcType)){
			this.emerProcTypeName = EmerProcTypeEnum.getName(emerProcType);
		}
		this.emerProcType = emerProcType;
	}

	public void setWorkOrderType(Integer workOrderType) {
		if(Func.isNotEmpty(workOrderType)){
			this.workOrderTypeName = WorkOrderTypeEnum.getName(workOrderType);
		}
		this.workOrderType = workOrderType;
	}

	public void setTypeStatus(Integer typeStatus) {
		this.typeStatus = typeStatus;
		this.typeStatusName = MaintainPlanContentEnum.getName(typeStatus);
	}

	public void setStatus(Integer status) {
		this.status = status;
		this.statusName = TaskStatusEnum.getTaskName(MaintainPlanContentEnum.MAINTAIN_PARTS.getId(), status);
	}

}
